<script>
	export default {
		onLaunch: function() {
			// if(!uni.getStorageSync('adressNow')){
			// 	this.getLocation()
			// }
			console.log('App Launch')
		},
		onShow: function() {
			console.log('App Show')
		},
		onHide: function() {
			console.log('App Hide')
		},
		methods: {
			getLocation() {
				let that = this
				uni.getLocation({
					type: 'gcj02', // 使用国测局坐标系
					success: function(res) {
						that.longitude = res.longitude
						that.latitude = res.latitude
						uni.request({
							url: `https://apis.map.qq.com/ws/geocoder/v1`,
							method: 'POST',
							data: {
								coord_type: 5,
								get_poi: 0,
								output: 'json',
								key: 'W4WBZ-TUD65-IDAIR-QPM36-HMFQ5-CGBZP',
								location: `${res.latitude},${ res.longitude}`
							},
							success(res) {
								uni.setStorageSync('adressNow', res.data.result.address);
								uni.setStorageSync('locationNow', res.data.result.location);
							},
							fail: (err) => {
								console.log(err);
								uni.hideLoading();
							},
						})
					},
					fail: function(err) {
						console.log('获取位置信息失败: ' + err.errMsg);
					}
				});
			},
		}
	}
</script>

<style lang="scss">
	@import './style/thorui-extend.css';
	@import './style/index.scss';
	

	/*每个页面公共css */
</style>